package reflect;

import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws Exception {
        Person p = new Person();
        System.out.println(p);

        /*反射机制实例化
        * 1获取相对应的类对象
        * 2通过类对象的newInstance（）方法实例化*/
        /*Class cls = Person.class;*/
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个类的完全限定名");
        String classname = scanner.nextLine();

        Class cls = Class.forName(classname);
        Object obj = cls.newInstance();
        System.out.println(obj);
    }
}
